package com.chen.androidstudy.receiver;

import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
import android.util.Log;

/**
 * @Author: CHong
 * @CreateDate: 2024/8/27 0027
 * @Description:
 */
public class SimStateReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals("android.intent.action.SIM_STATE_CHANGED")) {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE);
            int state = tm.getSimState();
            if(state == TelephonyManager.SIM_STATE_READY){
                Log.e("chen","----------可用--------");
            } else if (state == TelephonyManager.SIM_STATE_ABSENT){
                Log.e("chen","----------不可用--------");
            } else {
                Log.e("chen","----------state--------" + state);
            }
        }
    }
}
